#! /usr/bin/python
#coding=utf-8

"""
file    : vpnserver.release.py
author  : Dragon.Chen
version : V1.0.0
date    : 01-13-2015
brief   : 生成release版本
company : COPYRIGHT 2015 上海今中网络科技有限公司
"""

import os, sys, string

def main():
    fileName    = '../basement.h'
    fileNameBak = '../basement.h.bak'
    oldMark     = '//#undef  ENABLE_DEBUG'
    newMark     = '#undef  ENABLE_DEBUG\n'
    
    workdir = os.getcwd()
    print(workdir)
    if workdir.endswith('python') == False :
        os.chdir(workdir + '/python')

    fileHandle    = open(fileName, 'r')
    fileBakHandle = open(fileNameBak, 'w')

    lineString = fileHandle.readline()
    while lineString :
        line = lineString.strip()
        if line.startswith(oldMark):
            fileBakHandle.writelines(newMark)
        else:
            fileBakHandle.writelines(lineString)
        lineString = fileHandle.readline()

    fileHandle.close()
    fileBakHandle.close()

    os.remove(fileName)
    os.rename(fileNameBak, fileName)

if __name__ == '__main__':
    main()

